home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / INVS.N < prev    next >
Text File  |  1995-11-08  |  6KB  |  172 lines

  1. Define InvRepPageHead(doc, head, page, line, linesperpage) {
  2.     if (page)
  3.         PdPageFeed(doc);
  4.     PdWrite(doc, PfFormat(head, "", 
  5.                         StrCat("page ", page = page + 1)));
  6.                         line = linesperpage;
  7. }
  8. Define InvRepProcType(doc, scr, head, dtl, des, 
  9.                       page, line, linesperpage, type, desc) {
  10.     if (line <= 3)
  11.         InvRepPageHead(doc, head, &page, &line, linesperpage);
  12.     PdWrite(doc, PfFormat(des, "", desc));
  13.     line -= 3;
  14.  
  15.     while (1) {
  16.         Explode(next(glob^inv_stat^[type]^[code]^[nvar]), "^", &p1, &p2, &code);
  17.         
  18.         if (p1 != "inv_stat" || p2 != type)
  19.             break;
  20.         if (abort = MsgShow(scr, desc . " " . code))
  21.             break;
  22.         if (line <= 1) 
  23.             InvRepPageHead(doc, head, &page, &line, linesperpage);
  24.         PdWrite(doc, PfFormat(dtl, "", 
  25.                               code, 
  26.                               univ^[type]_code^[code],
  27.                               glob^inv_stat^[type]^[code]^cnt,
  28.                               glob^inv_stat^[type]^[code]^vamt,
  29.                               glob^inv_stat^[type]^[code]^base,
  30.                               glob^inv_stat^[type]^[code]^extr));
  31.         line -= 1;
  32.         nvar = "zzzz";
  33.     }
  34.     return abort;
  35. }
  36. Define InvRepStat() {
  37. /*
  38.     glob^inv_stat^vtyp^mv^cnt           (I know base comes before cnt)
  39.     .....................^base
  40.     .....................^extr
  41.     .....................^vamt
  42.     ..................^nmv^cnt
  43.     ......................^base
  44.     ......................^vamt
  45.     .............^ptyp^d^cnt
  46.     ....................^base
  47.     ....................^extr
  48.     ....................^vamt
  49.     ..................^ft^cnt
  50.     .....................^base
  51.     .....................^extr
  52.     .....................^vamt
  53.     etc
  54. */
  55.     if (PeriodStartEndGet("Invoice Statistics Report", &fromDate, &toDate) != 1)
  56.         return;
  57.     scr = MsgCreate("Invoice Statistics Report");
  58.  
  59.     while (1) {                     /* clear where we accumulate stats */
  60.                                     /* other way is to open the temp file ! */
  61.         Explode(next(glob^inv_stat^[type]^[code]^[item]),
  62.                 "^", &p1, &type, &code, &item);
  63.         if (p1 != "inv_stat")
  64.             break;
  65.         glob^inv_stat^[type]^[code]^[item] = "";
  66.     }
  67.     glob^inv_stat^total^cnt = 0;
  68.     glob^inv_stat^total^vamt = 
  69.     glob^inv_stat^total^base =
  70.     glob^inv_stat^total^extr = 0.0;
  71.  
  72.     date = fromDate;
  73.     code = "";
  74.     while (1) {
  75.         Explode(next(data^inv_date^[date]^[code]), "^", &p1, &date, &code);
  76.  
  77.         if (p1 != "inv_date" || date > toDate)
  78.             break;
  79.  
  80.         if (abort = MsgShow(scr, date . " Invoice " . code))
  81.             break;
  82.  
  83.         vtyp = data^inv^[code]^vtyp;
  84.         vamt = data^inv^[code]^vamt;
  85.         base = data^inv^[code]^base;
  86.         extr = data^inv^[code]^extr;
  87.         glob^inv_stat^vtyp^[vtyp]^cnt  += 1;
  88.         glob^inv_stat^vtyp^[vtyp]^vamt += vamt;
  89.         glob^inv_stat^vtyp^[vtyp]^base += base;
  90.         glob^inv_stat^vtyp^[vtyp]^extr += extr;
  91.  
  92.         ptyp = data^inv^[code]^ptyp;
  93.         glob^inv_stat^ptyp^[ptyp]^cnt  += 1;
  94.         glob^inv_stat^ptyp^[ptyp]^vamt += vamt;
  95.         glob^inv_stat^ptyp^[ptyp]^base += base;
  96.         glob^inv_stat^ptyp^[ptyp]^extr += extr;
  97.  
  98.         glob^inv_stat^total^cnt += 1;
  99.         glob^inv_stat^total^vamt += vamt;
  100.         glob^inv_stat^total^base += base;
  101.         glob^inv_stat^total^extr += extr;
  102.     }
  103.  
  104.     if (!abort) {
  105.         doc = PdCreate(parm^prt^def^name, "InvRepStat", parm^prt^def^append, 
  106.                        parm^prt^def^copies, parm^prt^def^browse, 
  107.                        0, 85, 0, "",
  108.                        parm^prt^def^start, parm^prt^def^end);
  109.         PdPageSize(doc, parm^page^def^height, 
  110.                         parm^page^def^width,
  111.                         parm^page^def^margin^top, 
  112.                         parm^page^def^margin^bottom,
  113.                         parm^page^def^margin^left, 
  114.                         parm^page^def^margin^right);
  115.  
  116.         head = PfCreate();
  117.         PfPrompt(head, 0,  0, univ^spar^coname);
  118.         PfPrompt(head, 0, 50, DateToday());
  119.         PfPrompt(head, 0, 62, TimeNow());
  120.         PfString(head, 0, 71, 10, "R");
  121.         PfPrompt(head, 0, 82, "of");
  122.         PfPrompt(head, 2, 20, StrCat("Invoice Statistics for ", fromDate, " to ", toDate));
  123.         PfPrompt(head, 4,  0, "Code     Description");
  124.         PfPrompt(head, 4, 51, "#Vals    Val Amt  Base Fees    Extras");
  125.         PfPrompt(head, 5,  0, " ");
  126.  
  127.         dtl = PfCreate();
  128.         PfString(dtl,  0,  0, 8);
  129.         PfString(dtl,  0,  9, 40);
  130.         PfInt   (dtl,  0, 50, 6);
  131.         PfFloat (dtl,  0, 56, 11, 0);
  132.         PfFloat (dtl,  0, 67, 11, 2);
  133.         PfFloat (dtl,  0, 78, 10, 2);
  134.  
  135.         des = PfCreate();
  136.         PfString(des,  1,  0, 50);
  137.         PfPrompt(des,  2,  0, " ");
  138.  
  139.  
  140.         PdWrite(doc, PfFormat(head, "", StrCat("page ", page = page + 1)));
  141.         linesperpage = line = parm^page^def^height -
  142.                             parm^page^def^margin^top - 
  143.                             parm^page^def^margin^bottom - 5;
  144.  
  145.         while (1) {
  146.             if (abort = InvRepProcType(doc, scr, head, dtl, des, 
  147.                                        &page, &line, linesperpage, 
  148.                                        "vtyp", "Valuation Types"))
  149.                 break;
  150.             if (abort = InvRepProcType(doc, scr, head, dtl, des,
  151.                                        &page, &line, linesperpage, 
  152.                                        "ptyp", "Property Types"))
  153.                 break;
  154.  
  155.             if (line <= 4)
  156.                 InvRepPageHead(doc, head, &page, &line, linesperpage);
  157.             PdWrite(doc, PfFormat(des, "", "Total Valuations"));
  158.             PdWrite(doc, PfFormat(dtl, "", "", "", glob^inv_stat^total^cnt,
  159.                                                    glob^inv_stat^total^vamt,
  160.                                                    glob^inv_stat^total^base,
  161.                                                    glob^inv_stat^total^extr));
  162.             break;
  163.         }
  164.  
  165.         PfDestroy(head);
  166.         PfDestroy(dtl);
  167.         PfDestroy(des);
  168.         PdClose(doc, abort);
  169.     }
  170.     MsgDestroy(scr);
  171. }
  172.